package com.meshnetics.gb.type.impl.zcl;

import com.meshnetics.gb.type.DataTypeID;

/**
 * WRITE DESCRIPTION HERE
 *
 * @author AKovylin
 */
public class TypeEnumeration extends FixedBytesDataType {
    private static final String ALIAS_PEFIX = "enum";
    private static final String ID_TYPE_CLASS = "Enumeration";
    private static final String ID_DATA_TYPE_POSTFIX = "-bit enumeration";

    public static final TypeEnumeration ENUM_8 = new TypeEnumeration(1,
            new DataTypeID((byte) 0x30, ID_TYPE_CLASS, 8 + ID_DATA_TYPE_POSTFIX));
    public static final TypeEnumeration ENUM_16 = new TypeEnumeration(2,
            new DataTypeID((byte) 0x31, ID_TYPE_CLASS, 16 + ID_DATA_TYPE_POSTFIX));

    protected TypeEnumeration(int byteSize, DataTypeID dataTypeId) {
        super(new String[]{ALIAS_PEFIX + byteSize * BITS_IN_BYTE}, dataTypeId, byteSize);
    }

    protected TypeEnumeration(String[] aliases, DataTypeID dataTypeId, int byteSize) {
        super(aliases, dataTypeId, byteSize);
    }

    // no byte array cloning needed
    protected FixedBytesDataValue createValue(byte[] bytes) {
        return new EnumElement(this, bytes);
    }
}
